package com.thirdgroup.dao.impl;

import com.thirdgroup.dao.CusInfoDao;
import com.thirdgroup.pojo.entity.CustomerInfo;
import org.junit.Test;

import java.text.SimpleDateFormat;
import java.util.Date;

import static org.junit.Assert.*;

public class CusInfoDaoImplTest {
    private CusInfoDao cusInfoDao=new CusInfoDaoImpl();

    @org.junit.Test
    public void selectAll() {
        for (CustomerInfo customerInfo : cusInfoDao.selectAll()) {
            System.out.println(customerInfo);
        }

    }

    @Test
    public void updateState() {
        // 创建当前日期对象
        Date date = new Date();
        // 创建 SimpleDateFormat 对象，指定日期时间格式
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        // 使用 SimpleDateFormat 格式化日期时间
        String formattedDate = formatter.format(date);
        Integer integer = cusInfoDao.updateState("C20220102112159", "使用中",formattedDate);
        System.out.println("修改"+integer+"条数据");
    }

    @Test
    public void delete() {
        Integer c2 = cusInfoDao.delete("C20240515101104");
        System.out.println(c2);
    }

    @Test
    public void detail() {
        CustomerInfo c3 = cusInfoDao.detail("C20240515100642");
        System.out.println(c3);
    }

    @Test
    public void updateBalance() {
        cusInfoDao.updateBalance("C20220102112159", 300.0);
        CustomerInfo cs = cusInfoDao.detail("C20220102112159");
        System.out.println(cs);
    }
}